<template>
	<div class="tab-front accountManage">
		<el-tabs v-model="activeName[0]" @tab-click="tabClick1">
			<el-tab-pane label="系统参数" name="first">
				<div class="block2 relative" v-if="activeName[0] === 'first'">
					<el-tabs v-model="activeName2">
						<el-tab-pane label="系统信息" name="section1">
							<system-info v-if="activeName2 == 'section1'"/>
						</el-tab-pane>
						<el-tab-pane label="会计区间" name="section2">
							<account-year v-if="activeName2 == 'section2'"/>
						</el-tab-pane>
						<el-tab-pane label="财务参数" name="section3">
							<fd-params v-if="activeName2 == 'section3'"/>
						</el-tab-pane>
					</el-tabs>
					<div class="btn-group right" v-if="activeName2 === 'section1'">
						<el-button type="primary" v-if="status[0] == 1" disabled>保存</el-button>
						<el-button type="primary" v-else @click="save">保存</el-button>
						<el-button type="warning" v-if="status == 1">修改</el-button>
						<el-button type="danger" @click="close">关闭</el-button>
						<el-button-group class="btn-other">
			                <el-button title="导出">
			                    <img src="../../../assets/images/export.png" alt="">
			                </el-button>                     
			                <el-button title="打印">
			                    <img src="../../../assets/images/print.png" alt="">
			                </el-button>
			                <el-button title="帮助">
			                    <img src="../../../assets/images/help.png" alt="">
			                </el-button>
			            </el-button-group>
					</div>
				</div>
			</el-tab-pane>
			<el-tab-pane label="账套列表" name="second">
				<account-list v-if="activeName[0] === 'second'"/>
			</el-tab-pane>
		</el-tabs>
	</div>
</template>
<script>
/*
*  author: 'iissoftware'
*  description: 账套管理组件
*/
import accountList from './accountList'
import systemInfo from './systemInfo'
import accountYear from './accountYear'
import FDParams from './FDParams'
export default {
	components: {
		'account-list': accountList,
		'system-info': systemInfo,
		'account-year': accountYear,
		'fd-params': FDParams
	},
	data() {
		return {
			activeName: this.$store.state.accountStore.activeName,
			activeName2: 'section1',
			status: this.$store.state.accountStore.status,		//当前操作状态
		}
	},
	watch: {
		activeName(newVal) {
			if(newVal[0] === 'first') {
				this.activeName2 = 'section1';
			}
			if(newVal[0] === 'second') {
				this.$store.commit('accountStore/updateStatus', 2);
			}
		}
	},
	methods: {
		tabClick1() {
			// console.log(this.activeName);
		},
        update() {		//修改账套信息
        	
        },
		save() {		//保存信息
			if(this.status.length == 0 || this.status[0] == 2 || this.status[0] == 3) {
				this.$store.commit('accountStore/updateStatus', 3);
			} else if(this.status[0] == 4) {
				this.$store.commit('accountStore/updateStatus', 4);
			} else if(this.status[0] == 5 || this.status[0] == 6) {
				this.$store.commit('accountStore/updateStatus', 6);
			}
        },
        close() {		//关闭
			let index = parent.layer.getFrameIndex(window.name);    //先得到当前iframe层的索引
            parent.layer.close(index);
		}
	}
}
</script>
<style scoped>
	.tab-front .el-tabs__content {height: calc(100% - 40px) !important;}
	.btn-group {
		position: absolute;
		top: 0;
		right: 0;
	}
	.block2 {height: 100%;}
</style>